import React, { memo } from 'react'
import { Checkbox } from 'antd'
import { ToolNode } from './interface'
import styles from './table.module.scss'

interface IProps {
  total: number;
  checked: boolean;
  loading: boolean;
  toolNode: ToolNode;
  onChange(): void
}

export default memo(({ total, toolNode, onChange, checked, loading }: IProps) => {
  return total ? (
    <div className={styles.toolBar}>
      <Checkbox indeterminate={!checked} disabled={loading} checked={checked || true} onChange={onChange}>
        {window.$app.t("chooseAll")}(<span className={styles.selectTotal}>{total}</span>{window.$app.t("tiao")})
      </Checkbox>
      { !loading && toolNode() }
    </div>
  ) : null
})